#!/bin/bash

########################################################################################################################
#
#											debmake - Debian packaging tool
#
#	Helps developers to make debian (.deb) package from sources
#
#	Version : 0.1
#	Date : 07/02/2012
#	Author : Pierre-Marie Dhaussy <pierremarie.dhaussy@gmail.com>
#
########################################################################################################################

function _PackageName() {
	grep -i "package:" "$1" | cut -c 10-
}

function _PackageVersion() {
	grep -i "version:" "$1" | cut -c 10-
}

function _PackageArchitecture() {
	grep -i "architecture:" "$1" | cut -c 15-
}

function _PrepareWorkingDirectory() {
	WKG_DIR="$1/`_PackageName $2`_`_PackageVersion $2`_`_PackageArchitecture $2`"
	rm -r -f "$WKG_DIR"
	mkdir -p "$WKG_DIR"
	echo "$WKG_DIR"
}

function _CopyContentIgnoreHidden() {
	rsync -r --exclude=.svn "$1"/* "$2"
}

function _CopyCreateDir() {
	mkdir -p "$2"
	cp -Rf "$1" "$2"
}

function _MakeDeb() {
	dpkg-deb --build "$1" "$2"
	rm -Rf "$1"
}
